package com.nf.dao;

import com.nf.entity.Student;
import com.nf.util.HisConnectionImpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class StudentdaoImpl implements Studentdao {
    private Connection conn;
    public Student getStudentById(int i) {
        conn=new HisConnectionImpl().getConnection();
        PreparedStatement pst=null;
        ResultSet rs;
        Student student=null;
        try {
            pst=conn.prepareStatement("select * from cale where id=?");
            pst.setInt(1,i);
            rs=pst.executeQuery();
            if(rs.next()){
                Student s=new Student();
                System.out.print("查询到学生的id:"+i);
                s.setId(rs.getInt("id"));
                s.setUserName(rs.getString(""));
            }else{
                System.out.print("查询不到到学生的id:"+i);
            }
            pst.close();
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return student;
    }

    public List<Student> getStudentAll() {
        return null;
    }

}
